home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93b.txt / 000051_icon-group-sender _Wed Apr 28 13:56:23 1993.msg < prev    next >
Internet Message Format  |  1993-06-16  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Mon, 3 May 1993 05:25:22 MST
  2. Date: 28 Apr 93 13:56:23 GMT
  3. From: mercury.hsi.com!mlfarm!cs.arizona.edu!icon-group@uunet.uu.net  (Chris Tenaglia - 257-8765)
  4. Organization: Medical College of Wisconsin (Milwaukee, WI)
  5. Subject: Re: Help!
  6. Message-Id: <01GXJCRBTCHU8WW7RY@mis.mcw.edu>
  7. Sender: icon-group-request@cs.arizona.edu
  8. To: icon-group@cs.arizona.edu
  9. Status: R
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11.  
  12.  
  13. On Passing several variables In and several Out:
  14.  
  15. Structures and globals are the methods I use. Structures are better if
  16. you  have  this as a widespread problem. Globals are useful in smaller
  17. cases. I use globals a lot when converting a BASIC program into ICON.
  18.  
  19. ----------------------------------------------------------------------
  20.  
  21. Method 1 : Use a structure
  22.  
  23.           stuff := obtain(a,b,c)
  24. ...
  25. # Using a List                        # Using a table
  26. procedure obtain(a,b,c)     or        procedure obtain(a,b,c)
  27.   return [x,y,z]                        result := table("")
  28.   end                                   result["x"] := 5*1.4
  29.                                         result["y"] := 22/7
  30.                                         result["z"] := ?25
  31.                                         return result
  32.                                         end
  33. ------------------------------------------------------------------------------
  34. Method 2. Use globals
  35.  
  36. global x,y,z
  37. procedure main()
  38. ...
  39.    obtain(a,b,c)
  40. end
  41.  
  42. procedure obtain(a,b,c)
  43.    x := 5*1.3
  44.    y := 22/7
  45.    z := ?25
  46.    end
  47. ---------------------------------------------------------------------
  48.  
  49. Chris Tenaglia (System Manager) |  "The past explained,
  50. Medical College of Wisconsin    |   the future fortold, 
  51. 8701 W. Watertown Plank Rd.     |   the present largely appologized for."
  52. Milwaukee, WI 53226             |   Organon to The Doctor
  53. (414)257-8765                   |     
  54. tenaglia@mis.mcw.edu
  55.